<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>按键修饰符</title>
</head>

<body>
    <div id="app">
        <form action="">
            <div>
                用户名：
                <input type="text" v-on:keyup.delete="clearContent" v-model="username" />
            </div>
            <div>
                密码：
                <input type="text" v-on:keyup.enter="handleSubmit" v-model="password" />
            </div>
            <div>
                <input type="button" v-on:click="handleSubmit" value="提交" />
            </div>
        </form>
    </div>

    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">
        var vm = new Vue({
            el: '#app',
            data: {
                username: '',
                password: ''
            },
            methods: {
                clearContent: function () {
                    this.username = '';
                },
                handleSubmit: function () {
                    console.log('提交');
                }
            }
        });
    </script>
</body>

</html>